package com.example.blogdemo1.common.model;

/*
 * @author zzr
 * @date: 2025/10/05  17:43
 * @description:
 */

import com.example.blogdemo1.common.enums.ResultCodeEnum;
import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String errMsg;
    private T data;

    public static <T> Result succcess(T data) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.SUCCESS.getCode());
        result.setData(data);
        return result;
    }

    public static <T> Result fail(String errMsg) {
        Result result = new Result();
        result.setErrMsg(errMsg);
        result.setCode(ResultCodeEnum.FAIL.getCode());
        return result;
    }
}
